Skip to content

feat(smartqa-host): wait up to 10 s for the host recorder before a host run starts (CHE-1098 stage 4b) [squash] - #339

Open
congvc-bot-x99[bot] wants to merge 5 commits into
mainfrom
agent/x99-claude-sonnet/che-9900-2b4cd1e19319
Open

congvc-bot-x99[bot] wants to merge 5 commits into
mainfrom
agent/x99-claude-sonnet/che-9900-2b4cd1e19319

Conversation

@congvc-bot-x99

Copy link
Copy Markdown

Status

Draft. Server only. Code and tests only. No host (Go) change, no UI, no deploy.

Conditions

  • Everything is behind the new default-off flag ARTEMIS_HOST_RECORDING. It is on only when ARTEMIS_HOST_AGENT is also on. Off means today's behavior.
  • No live push of assignments to the host. The deployed host agent drops the connection on an unknown message type. The host gets assignments from the connected snapshot only. A live recordings message ships with stage 8, together with its Go handler.

Change

  • artemis/config/host_agent.py: host_recording_enabled(), read on every call.
  • task_queue_service.py _execute_task_item: for a run with target.host_id and a session id, with the flag on, before worker_spawned is set:
    1. assign(host_id, session_id, generation).
    2. set_recording_state(..., capture="pending").
    3. wait_ready in a thread (10 s default).
    4. Ready gives capture="recording". No signal gives capture="missing:not_ready" and the log line event=recorder_not_ready session_id=... host_id=.... The worker spawns in both cases.
  • The run never fails because of the recorder: an error in this block is logged and the worker spawns.
  • Stop: request_stop(session_id) after _persist_terminal_session_status and in the spawn-failure path. A requeue does not stop it. A host NACK during the wait still requeues, and the next attempt assign returns the same row.
  • RecordingAssignment.server_started_at is host_started_at + clock_offset when both are set, else None. Stage 6 writes it to video_recordings.start_time.

Blast Radius

  • Affected: host-bound runs when both flags are on. With the flag off (default) no new code path runs except one flag read per host run.
  • Not affected: runs without host_id, hosts, the WebSocket protocol, the database schema.
  • Detection: the recorder_not_ready log line; run_recording_state.capture reads missing:not_ready.
  • Proof level: 2 (unit). No end-to-end run. No host recorder exists until stage 8.

Evidence

Test command: uv run pytest tests/unit/admin_console -q

Red, before the change (new tests only, test_host_recording_wait.py and test_recording_assignments.py):

FAILED test_recording_assignments.py::test_server_started_at_is_host_start_plus_clock_offset[1000.0-5.0-1005.0]
FAILED test_recording_assignments.py::test_server_started_at_is_host_start_plus_clock_offset[1000.0-None-None]
FAILED test_recording_assignments.py::test_server_started_at_is_host_start_plus_clock_offset[None-5.0-None]
FAILED test_recording_assignments.py::test_server_started_at_is_host_start_plus_clock_offset[None-None-None]
ERROR  test_host_recording_wait.py (8 tests: no TaskQueueService._recording_store)
4 failed, 13 passed, 9 warnings, 8 errors in 18.91s

Green, after the change:

tests/unit/admin_console: 2264 passed, 4 skipped, 1 deselected, 78 warnings in 434.55s
new + test_host_nack_races.py after formatting: 38 passed
ruff check and ruff format --check: clean

The wait uses a fake clock and sleep in the store. No real 10 s wait.

Refs CHE-1087

@congvc-bot-x99
congvc-bot-x99 Bot marked this pull request as ready for review November 30, 2026 10:15
…ssion repo a real lifecycle db_path (CHE-1098 stage 4b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants